package ynu.sxp.demoapp.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import ynu.sxp.demoapp.entity.Food;
import ynu.sxp.demoapp.repository.FoodRepository;
import ynu.sxp.demoapp.service.FoodService;

import java.util.List;

@Service
public class FoodServiceImpl implements FoodService {
    private final FoodRepository foodRepository;

    @Autowired
    public FoodServiceImpl(FoodRepository foodRepository) {
        this.foodRepository = foodRepository;
    }

    @Override
    public List<Food> getFoodsByBusinessId(Integer businessId) {
        return foodRepository.findByBusinessId(businessId);
    }

    @Override
    public List<Food> getAllFoods() {
        return foodRepository.findAll(); // 获取所有食品信息
    }
}